home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK2.toast / Development Kits / Telephone Manager / Stiletto Sources / ModuleSources / ToolFunctions.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-06  |  9.3 KB  |  321 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    ToolFunctions                                                                */
  4. /*                                                                                                */
  5. /*    File Name:        ToolFunctions.c                                                                */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-08-02    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21.     This module calls TELToolFunctions on the passed termHand.
  22.  
  23. *************************************************************************************************/
  24.  
  25. /******************************************** HEADERS *******************************************/
  26.  
  27. #include "Resources.h"
  28.  
  29. #ifndef __TELEPHONETOOLS__
  30. #include "TelephoneTools.h"
  31. #endif
  32.  
  33. #include "TestModule.h"
  34.  
  35. /****************************************** DEFINITIONS *****************************************/
  36.  
  37. #define rToolFunctionDLOG        10000
  38. #define    kUnsupportedToolsRadio    4
  39. #define    kSupportedToolsRadio    5
  40. #define    kAllToolsRadio            6
  41.  
  42. #if defined(powerc) || defined (__powerc)
  43. #pragma options align=mac68k
  44. #endif
  45. struct MessagesStructure {
  46.     char    *name;
  47.     short    msg;
  48. };
  49. #if defined(powerc) || defined(__powerc)
  50. #pragma options align=reset
  51. #endif
  52.  
  53. typedef struct MessagesStructure MessagesStructure;
  54.  
  55. #if defined(powerc) || defined (__powerc)
  56. #pragma options align=mac68k
  57. #endif
  58. struct RadioStructure {
  59.     short    min;
  60.     short    max;
  61.     short    current;
  62. };
  63. #if defined(powerc) || defined(__powerc)
  64. #pragma options align=reset
  65. #endif
  66.  
  67. typedef struct RadioStructure RadioStructure;
  68.  
  69. /****************************************** PROTOTYPES ******************************************/
  70.  
  71. short    DisplayToolFunctionDialog (CHRSPtr paramPtr, short *option);
  72. void     DoTest (CHRSPtr paramPtr);
  73.  
  74. /************************************************************************************************/
  75. /************************************************************************************************/
  76.  
  77.  
  78. pascal short TestModule (CHRSPtr paramPtr)
  79. {
  80.     short    returnValue = noErr;
  81.     
  82.     if (paramPtr->version <= kTestModuleVersion) {
  83.         
  84.         DoTest (paramPtr);
  85.         
  86.     }
  87.     else
  88.         returnValue = kWrongVersion;
  89.         
  90.     return (returnValue);
  91. }
  92.  
  93.  
  94.  
  95. void DoTest (CHRSPtr paramPtr)
  96. {
  97.     TELHandle            termHand = GetCurrentTELHandle (paramPtr);
  98.     OSErr                errCode;
  99.     Boolean                supportsIt;
  100.     short                index, option;
  101.     MessagesStructure     array[] = {
  102.         { "telGetInfoMsg",            telGetInfoMsg },        
  103.         { "telOpenTermMsg",            telOpenTermMsg },        
  104.         { "telResetTermMsg",        telResetTermMsg },        
  105.         { "telCloseTermMsg",        telCloseTermMsg },    
  106.  
  107.         { "telTermMsgHandMsg",        telTermMsgHandMsg },
  108.         { "telClrTermMsgHandMsg",    telClrTermMsgHandMsg },
  109.         { "telTermEventsSuppMsg",    telTermEventsSuppMsg },
  110.  
  111. //        { "telGetProcIDMsg",        telGetProcIDMsg },
  112.         { "telNewMsg",                telNewMsg },
  113.         { "telDefaultMsg",            telDefaultMsg },
  114.         { "telValidateMsg",            telValidateMsg },
  115. //        { "telGetConfigMsg",        telGetConfigMsg },
  116. //        { "telSetConfigMsg",        telSetConfigMsg },
  117. //        { "telChooseMsg",            telChooseMsg },
  118.  
  119.         { "telSpreflightMsg",        telSpreflightMsg },
  120.         { "telSsetupMsg",            telSsetupMsg },
  121.         { "telSfilterMsg",            telSfilterMsg },
  122.         { "telSitemMsg",            telSitemMsg },
  123.         { "telScleanupMsg",            telScleanupMsg },
  124. //        { "telSpostFlightMsg",        telSpostFlightMsg },
  125.         { "telDisposeMsg",            telDisposeMsg },
  126.  
  127.  
  128.         { "telCountDNsMsg",            telCountDNsMsg },        
  129.         { "telDNLookupByIndexMsg",    telDNLookupByIndexMsg },    
  130.         { "telDNLookupByNameMsg",    telDNLookupByNameMsg },    
  131.         { "telGetDNInfoMsg",        telGetDNInfoMsg },
  132.         { "telDNSelectMsg",            telDNSelectMsg },
  133.         { "telDNDisposeMsg",        telDNDisposeMsg },
  134.         { "telGetDNFlagsMsg",        telGetDNFlagsMsg },
  135.  
  136.         { "telDNMsgHandMsg",        telDNMsgHandMsg },
  137.         { "telClrDNMsgHandMsg",        telClrDNMsgHandMsg },
  138.         { "telDNEventsSuppMsg",        telDNEventsSuppMsg },
  139.  
  140.  
  141.         { "telCountCAsMsg",            telCountCAsMsg },
  142.         { "telCALookupMsg",            telCALookupMsg },
  143.         { "telGetCAInfoMsg",        telGetCAInfoMsg },
  144.         { "telCADisposeMsg",        telCADisposeMsg },
  145.         { "telGetCAStateMsg",        telGetCAStateMsg },
  146.         { "telGetCAFlagsMsg",        telGetCAFlagsMsg },
  147.  
  148.         { "telCAMsgHandMsg",        telCAMsgHandMsg },
  149.         { "telClrCAMsgHandMsg",        telClrCAMsgHandMsg },
  150.         { "telCAEventsSuppMsg",        telCAEventsSuppMsg },
  151.  
  152.         { "telSetupCallMsg",        telSetupCallMsg },
  153.         { "telConnectMsg",            telConnectMsg },
  154.         { "telDialDigitsMsg",        telDialDigitsMsg },
  155.  
  156.         { "telAcceptCallMsg",        telAcceptCallMsg },
  157.         { "telRejectCallMsg",        telRejectCallMsg },
  158.         { "telDeflectCallMsg",        telDeflectCallMsg },
  159.         { "telAnswerCallMsg",        telAnswerCallMsg },
  160.  
  161.         { "telDropMsg",                telDropMsg },
  162.  
  163.         { "telHoldMsg",                telHoldMsg },
  164.         { "telRetrieveMsg",            telRetrieveMsg },
  165.  
  166.         { "telConfPrepMsg",            telConfPrepMsg },
  167.         { "telConfEstMsg",            telConfEstMsg },
  168.         { "telConfSplitMsg",        telConfSplitMsg },
  169.  
  170.         { "telTransfPrepMsg",        telTransfPrepMsg },
  171.         { "telTransfEstMsg",        telTransfEstMsg },
  172.         { "telTransfBlindMsg",        telTransfBlindMsg },
  173.  
  174.         { "telForwardSetMsg",        telForwardSetMsg },
  175.         { "telForwardClearMsg",        telForwardClearMsg },
  176.  
  177.         { "telCallbackSetMsg",        telCallbackSetMsg },
  178.         { "telCallbackNowMsg",        telCallbackNowMsg },
  179.         { "telCallbackClearMsg",    telCallbackClearMsg },
  180.  
  181.         { "telDNDSetMsg",            telDNDSetMsg },
  182.         { "telDNDClearMsg",            telDNDClearMsg },
  183.  
  184.         { "telCallPickupMsg",        telCallPickupMsg },
  185.  
  186.         { "telParkCallMsg",            telParkCallMsg },
  187.         { "telRetrieveParkedCallMsg",    telRetrieveParkedCallMsg },
  188.  
  189.         { "telVoiceMailAccessMsg",    telVoiceMailAccessMsg },
  190.  
  191.         { "telPagingMsg",            telPagingMsg },
  192.  
  193.         { "telIntercomMsg",            telIntercomMsg },
  194.  
  195.         { "telOtherFunctionMsg",    telOtherFunctionMsg },
  196.         { "telOtherFeatListMsg",    telOtherFeatListMsg },
  197.         { "telOtherFeatImplMsg",    telOtherFeatImplMsg },
  198.         { "telToolFunctionsMsg",    telToolFunctionsMsg },
  199.  
  200.         { "telGetHookswMsg",        telGetHookswMsg },
  201.         { "telSetHookswMsg",        telSetHookswMsg },
  202.         { "telGetVolumeMsg",        telGetVolumeMsg },
  203.         { "telSetVolumeMsg",        telSetVolumeMsg },
  204.         { "telAlertMsg",            telAlertMsg },
  205.         { "telGetDisplayMsg",        telGetDisplayMsg },
  206.         { "telSetDisplayMsg",        telSetDisplayMsg },
  207.  
  208.         { "telActivateMsg",            telActivateMsg },
  209.         { "telDeactivateMsg",        telDeactivateMsg },
  210.         { "telResumeMsg",            telResumeMsg },
  211.         { "telSuspendMsg",            telSuspendMsg },
  212.         { "telMenuMsg",                telMenuMsg },
  213.         { "telEventMsg",            telEventMsg },
  214. //        { "telGetToolNameMsg",        telGetToolNameMsg },
  215. //        { "telGetVersionMsg",        telGetVersionMsg },
  216. //        { "telGetTELVersionMsg",    telGetTELVersionMsg },
  217.         { "telIdleMsg",                telIdleMsg },
  218.  
  219.         { "telL2EnglishMsg",        telL2EnglishMsg },
  220.         { "telL2IntlMsg",            telL2IntlMsg }
  221.     };
  222.  
  223.     if (DisplayToolFunctionDialog (paramPtr, &option) == ok)
  224.     {
  225.         switch (option) {
  226.             case kAllToolsRadio :
  227.                 for (index = 0; index < (sizeof(array) / sizeof(MessagesStructure)); ++index)
  228.                 {
  229.                     if ((errCode = TELToolFunctions (termHand, array[index].msg, &supportsIt)) == noErr)
  230.                         Print (paramPtr, "%s %s", (supportsIt?"√":" "), array[index].name);
  231.                     else {
  232.                         Print (paramPtr, "### TELToolFunctions failed : %d", errCode);
  233.                         break;
  234.                     }
  235.                 }
  236.                 break;
  237.                 
  238.             case kSupportedToolsRadio :
  239.                 for (index = 0; index < (sizeof(array) / sizeof(MessagesStructure)); ++index)
  240.                 {
  241.                     if ((errCode = TELToolFunctions (termHand, array[index].msg, &supportsIt)) == noErr)
  242.                     {
  243.                         if (supportsIt)
  244.                             Print (paramPtr, "√ %s", array[index].name);
  245.                     }
  246.                     else {
  247.                         Print (paramPtr, "### TELToolFunctions failed : %d", errCode);
  248.                         break;
  249.                     }
  250.                 }
  251.                 break;
  252.                 
  253.             case kUnsupportedToolsRadio :
  254.                 for (index = 0; index < (sizeof(array) / sizeof(MessagesStructure)); ++index)
  255.                 {
  256.                     if ((errCode = TELToolFunctions (termHand, array[index].msg, &supportsIt)) == noErr)
  257.                     {
  258.                         if (!supportsIt)
  259.                             Print (paramPtr, "  %s", array[index].name);
  260.                     }
  261.                     else {
  262.                         Print (paramPtr, "### TELToolFunctions failed : %d", errCode);
  263.                         break;
  264.                     }
  265.                 }
  266.                 break;
  267.         }
  268.     }
  269. }
  270.  
  271.  
  272. short    DisplayToolFunctionDialog (CHRSPtr paramPtr, short *option)
  273. {
  274.     DialogPtr        theDialog;
  275.     short            itemHit, index = 0;
  276.     short            itemKind;
  277.     Handle            itemHand;
  278.     Rect            itemRect;
  279.     RadioStructure    radio = {kUnsupportedToolsRadio,kAllToolsRadio,kUnsupportedToolsRadio};
  280.     
  281.     theDialog = GetNewDialog (rToolFunctionDLOG, nil, (WindowPtr)(-1L));
  282.     if (theDialog == nil) {
  283.         Print (paramPtr, "### Can't find the DLOG resource : %d", ResError());
  284.         return (-1);
  285.     }
  286.     
  287.     for (index = radio.min; index <= radio.max; ++index) {
  288.         GetDItem (theDialog, index, &itemKind, &itemHand, &itemRect);
  289.         SetCtlValue ((ControlHandle) itemHand, (index == radio.current)?1:0);
  290.     }
  291.     
  292.     ShowWindow (theDialog);
  293.     
  294.     do {
  295.         ModalDialog (nil, &itemHit);    
  296.             
  297.         switch (itemHit) {
  298.             case ok :
  299.                 *option = radio.current;
  300.                 break;
  301.             
  302.             case kUnsupportedToolsRadio :
  303.             case kSupportedToolsRadio :
  304.             case kAllToolsRadio :
  305.                 GetDItem (theDialog, radio.current, &itemKind, &itemHand, &itemRect);
  306.                 SetCtlValue ((ControlHandle) itemHand, 0);
  307.                 
  308.                 radio.current = itemHit;
  309.                 GetDItem (theDialog, itemHit, &itemKind, &itemHand, &itemRect);
  310.                 SetCtlValue ((ControlHandle) itemHand, 1);
  311.                 break;
  312.         }
  313.     } while ((itemHit != ok) && (itemHit != cancel));
  314.     
  315.     DisposDialog (theDialog);
  316.     
  317.     return (itemHit);
  318. }
  319.  
  320.  
  321.